package com.demo.ocr.filtering;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;

/**
 * @author: 李德才
 * @description: 图片输入输出工具
 * @create: 2021-06-06 16:15
 **/
public class ImageUtil {

    public static BufferedImage readImg(String src) {
        try {
            return ImageIO.read(new FileInputStream(src));
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }

    public static boolean writeImg(BufferedImage img, String format, String destPath) {
        try {
            return ImageIO.write(img, format, new File(destPath));
        } catch (IOException e) {
            e.printStackTrace();
        }
        return false;
    }
}
